package com.example.car.manager.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;

public class NetworkUtils {
	public final static int NONE=0;
	public final static int WIFI=1;
	public final static int MOBLE=2;
	public static int getState(Context context){
		ConnectivityManager manager=(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		State state = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
		if(state==State.CONNECTED||state==State.CONNECTING){
			return MOBLE;
		}
		// WIFI
		state = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
		if (state == State.CONNECTED || state == State.CONNECTING) {
			return WIFI;
		}
		return NONE;
	}
	public static boolean isWiFiState(Context context) {
		return WIFI == getState(context);
	}

	public static boolean isDisconnected(Context context) {
		return NONE == getState(context);
	}
}